﻿/*  ----------------------------------------------------------------------------
 *  Author:
 *  Chandra Shekhar Tripathi
 *  ----------------------------------------------------------------------------
 *  Product Name:
 *  DbDocumenter
 *  ----------------------------------------------------------------------------
 *  Year:
 *  2009
 *  ----------------------------------------------------------------------------
 *  File:
 *  Logger.cs
 *  ----------------------------------------------------------------------------
 */
namespace DBDocumenter.Exception
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    using log4net;
    using log4net.Config;

    #region Enumerations

    public enum LogLevel
    {
        Debug = 1,

        Error,

        Fatal,

        Info,

        Warn
    }

    public enum LogType
    {
        PresentationLayer,

        BusinessLayer,

        DataLayer
    }

    #endregion Enumerations

    public static class Logger
    {
        #region Fields

        /// <summary> 
        /// Create a logger for this static class
        /// </summary> 
        private static readonly ILog logger = LogManager.GetLogger(typeof(Logger));

        #endregion Fields

        #region Constructors

        /// <summary> 
        /// On construct - build logger object 
        /// </summary> 
        static Logger()
        {
            //XmlConfigurator.Configure();
        }

        #endregion Constructors

        #region Methods

        /// <summary>
        /// Write information to log
        /// </summary>
        /// <param name="logLevel">Level of information to write</param>
        /// <param name="message">Information to write to log</param>
        public static void WriteLog(LogType logType, LogLevel logLevel, String message)
        {
            message = logType.ToString() + ":-" + message;

            if (logLevel.Equals(LogLevel.Debug))
            {

                logger.Debug(message);

            }

            else if (logLevel.Equals(LogLevel.Error))
            {

                logger.Error(message);

            }
            else if (logLevel.Equals(LogLevel.Fatal))
            {

                logger.Fatal(message);

            }

            else if (logLevel.Equals(LogLevel.Info))
            {

                logger.Info(message);

            }

            else if (logLevel.Equals(LogLevel.Warn))
            {

                logger.Warn(message);

            }
        }

        #endregion Methods
    }
}